package com.vrv.common.resolver;

import java.util.HashMap;
import java.util.Map;

import com.vrv.common.UrlPrefix;

/**
 * @Description 请求参数
 *
 * @author 曹保利
 */
public class RequestParameter {
    /**
     * 服务URl
     */
    public String url;
    /**
     * 每页显示记录数
     */
    private int pageSize = 20;
    /**
     * 请求的当前页号
     */
    private int pageNumber = 0;
    /**
     * 请求参数
     */
    private Map<String, Object> args = new HashMap<String, Object>();

    public RequestParameter(String url) {

        if (null == url || "".equals(url)) {
            url = "";
        }

        if (!("" + url).contains("http:")) {
            // this.url = "http://192.168.1.137:8080/EDPDMServer" + "/" + url;
            this.url = UrlPrefix.getUrlPrefix2() + "/" + url;
        } else {
            this.url = url;
        }
    }

    public RequestParameter(String url, Map<String, Object> args) {
        this(url);
        getArgs().putAll(args);
    }

    /* Gettings && Settings */

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Map<String, Object> getArgs() {

        if (!this.args.containsKey("pageSize")) {
            this.args.put("pageSize", getPageSize());
        }
        if (!this.args.containsKey("pageNumber")) {
            this.args.put("pageNumber", getPageNumber());
        }
        return args;

    }

    public void setArgs(Map<String, Object> args) {
        this.args.putAll(args);
    }

    public void addArgs(String key, Object value) {
        this.args.put(key, value);
    }
}